<?php
if (!defined('IN_SYS')) {
    header('HTTP/1.1 403 Forbidden');
    exit(0);
}

/** 
* 错误处理类
* 
* 类中的函数可能会结束程序
* @author xzqiapchu(www.xzzhangqiaochu.top)
* @version v1.0.0.200203_alpha
*/
Class Err {
    /**
    * 系统错误
    *
    * 记录错误原因后结束程序
    * @param string $reason 错误原因
    * @param string $pos_file 错误文件路径
    * @param int $pos_line 错误行号
    * @return exit
    */
    static function sysErr($reason, $pos_file, $pos_line) {
        $file = fopen('./logs/error.php', 'a');
        $err_msg = date('Y-m-d H:i:s', time());
        $err_msg .= ' ' . $reason;
        $err_msg .= ' ' . $pos_file . '(Line ' . $pos_line . ')';
        $err_msg .= ' ' . $_SERVER['REQUEST_URI'];
        $err_msg .= ' ' . $_SERVER['REMOTE_ADDR'] . "\r\n";
        fwrite($file, $err_msg);
        fclose($file);
        $resopnse['status'] = 'error';
        $resopnse['reason'] = 'system_error';
        echo json_encode($resopnse);
        exit(0);
    }
}
